"""请求模型定义模块"""

from typing import Optional
from datetime import datetime

from pydantic import BaseModel, Field

from .enums import DetectionPlatform


class TextDetectionRequest(BaseModel):
    """文本检测请求模型"""
    
    text: str = Field(
        ..., 
        min_length=1, 
        max_length=50000, 
        description="待检测文本",
        example="这是一段需要检测的文本内容..."
    )
    platform: DetectionPlatform = Field(
        ..., 
        description="检测平台",
        example=DetectionPlatform.ZHIWANG
    )
    title: Optional[str] = Field(
        None, 
        max_length=200, 
        description="文本标题",
        example="学术论文标题"
    )
    author: Optional[str] = Field(
        None, 
        max_length=100, 
        description="文本作者",
        example="张三"
    )
    
    class Config:
        use_enum_values = True


class BatchDetectionRequest(BaseModel):
    """批量检测请求模型"""
    
    texts: list[TextDetectionRequest] = Field(
        ...,
        min_items=1,
        max_items=100,
        description="批量检测文本列表"
    )
    
    class Config:
        use_enum_values = True


class DetectionQueryRequest(BaseModel):
    """检测查询请求模型"""
    
    task_id: str = Field(
        ...,
        description="任务ID"
    )
    
    
class DetectionHistoryRequest(BaseModel):
    """检测历史查询请求模型"""
    
    page: int = Field(
        1,
        ge=1,
        description="页码"
    )
    size: int = Field(
        10,
        ge=1,
        le=100,
        description="每页数量"
    )
    platform: Optional[DetectionPlatform] = Field(
        None,
        description="筛选检测平台"
    )
    start_date: Optional[datetime] = Field(
        None,
        description="开始时间"
    )
    end_date: Optional[datetime] = Field(
        None,
        description="结束时间"
    )
    
    class Config:
        use_enum_values = True 